Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] fix connector mem scan limit adjustment when no chunk source #53112

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

dirtysalt
Copy link
Contributor

@dirtysalt dirtysalt commented Nov 22, 2024

Why I'm doing:

This is the further improvement on this PR: #50686

We find a bad case that

  • if there are many scan nodes
  • but most of them does not create any chunk source
  • the scan node which has chunk source uses a very few io tasks

And this case can be reproduced by following SQL

  • only select lo_orderkey from ICE has data
  • the MYSQL does not have any data.
set cbo_cte_reuse = false;
with ICE as (
 select lo_orderkey from iceberg.zz_iceberg_ssb_sf100_iceberg_parquet_lz4.lineorder_flat
),
MYSQL(id_int) as (
  select id_int from default_catalog.zya.ext_mysql where id_varchar = 'USA'
),
RESULT(x) as (
select lo_orderkey from ICE
UNION ALL (select lo_orderkey from ICE inner join [broadcast] MYSQL on ICE.lo_orderkey = MYSQL.id_int)
UNION ALL (select lo_orderkey from ICE inner join [broadcast] MYSQL on ICE.lo_orderkey + 1= MYSQL.id_int)
UNION ALL (select lo_orderkey from ICE inner join [broadcast] MYSQL on ICE.lo_orderkey + 2= MYSQL.id_int)
UNION ALL (select lo_orderkey from ICE inner join [broadcast] MYSQL on ICE.lo_orderkey + 3= MYSQL.id_int)
UNION ALL (select lo_orderkey from ICE inner join [broadcast] MYSQL on ICE.lo_orderkey + 4= MYSQL.id_int)
)
select count(distinct x) from RESULT;

So the execution profile looks like this

image

And if you look at PeakIOTasks of ICE table, it's very low probably like 3-4, which is bad.


The root cause is, since we have this PR: #50686

  • we preallocate $$ScanNodeNumber * 256MB$$ as total memory pool.
  • and each scan operator will adjust their chunk source usage from 256MB when creating chunk source.
  • and at last, each scan operator will release their chunk source usage down to 0 when doing close
  • and during this adjustment, those scan operators are sharing memory limit according to chunk source usage.

However, there is a corner case that: if the scan operator does not create any chunk source, it has no chance to adjust it's chunk usage back to 0. And it affects other scan operator's available mem limit, which leads to low io tasks.

What I'm doing:

This PR is to:

  • adjust chunk source usage when do_preapre and do_close. so it will do adjustment even there is no chunk source created.
  • at FE side, we change scan_node_number to more proper name connector_scan_node_number. So there won't be problems if there are no-connector scan node and connector scan nodes in a single query.

Fixes #50686

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@dirtysalt dirtysalt requested review from a team as code owners November 22, 2024 00:10
@wanpengfei-git wanpengfei-git requested a review from a team November 22, 2024 00:10
@dirtysalt dirtysalt changed the title [Enhancement] fix connector mem scan limit for no chunk source [Enhancement] fix connector mem scan limit adjustment when no chunk source Nov 22, 2024
Copy link
Contributor

@zombee0 zombee0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

gensrc/thrift/InternalService.thrift Show resolved Hide resolved
Youngwb
Youngwb previously approved these changes Nov 22, 2024
Copy link

sonarcloud bot commented Nov 22, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
7.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link

[BE Incremental Coverage Report]

fail : 8 / 11 (72.73%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exec/pipeline/fragment_executor.cpp 0 3 00.00% [241, 242, 243]
🔵 be/src/exec/pipeline/scan/connector_scan_operator.cpp 7 7 100.00% []
🔵 be/src/exec/pipeline/query_context.cpp 1 1 100.00% []

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 8 / 8 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/planner/OlapScanNode.java 1 1 100.00% []
🔵 com/starrocks/planner/MetaScanNode.java 3 3 100.00% []
🔵 com/starrocks/planner/ScanNode.java 1 1 100.00% []
🔵 com/starrocks/qe/scheduler/dag/JobSpec.java 2 2 100.00% []
🔵 com/starrocks/planner/SchemaScanNode.java 1 1 100.00% []

@dirtysalt dirtysalt enabled auto-merge (squash) November 25, 2024 02:52
@kangkaisen kangkaisen merged commit 14ccfcc into StarRocks:main Nov 25, 2024
49 of 52 checks passed
Copy link

@Mergifyio backport branch-3.4

@github-actions github-actions bot removed the 3.4 label Nov 25, 2024
Copy link

@Mergifyio backport branch-3.3

@github-actions github-actions bot removed the 3.3 label Nov 25, 2024
Copy link

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Nov 25, 2024
Copy link
Contributor

mergify bot commented Nov 25, 2024

backport branch-3.4

✅ Backports have been created

Copy link
Contributor

mergify bot commented Nov 25, 2024

backport branch-3.3

✅ Backports have been created

Copy link
Contributor

mergify bot commented Nov 25, 2024

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Nov 25, 2024
mergify bot pushed a commit that referenced this pull request Nov 25, 2024
…ource (#53112)

Signed-off-by: yanz <[email protected]>
(cherry picked from commit 14ccfcc)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/planner/MetaScanNode.java
#	fe/fe-core/src/main/java/com/starrocks/planner/OlapScanNode.java
#	fe/fe-core/src/main/java/com/starrocks/planner/ScanNode.java
#	fe/fe-core/src/main/java/com/starrocks/planner/SchemaScanNode.java
mergify bot pushed a commit that referenced this pull request Nov 25, 2024
…ource (#53112)

Signed-off-by: yanz <[email protected]>
(cherry picked from commit 14ccfcc)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/planner/OlapScanNode.java
#	fe/fe-core/src/main/java/com/starrocks/planner/ScanNode.java
#	fe/fe-core/src/main/java/com/starrocks/planner/SchemaScanNode.java
@dirtysalt dirtysalt deleted the fix-alloc branch November 25, 2024 03:21
wanpengfei-git pushed a commit that referenced this pull request Nov 25, 2024
wanpengfei-git pushed a commit that referenced this pull request Nov 25, 2024
wanpengfei-git pushed a commit that referenced this pull request Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants